﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

namespace MVCBugTracker.Areas.UserManagement.Models
{
     public interface IMembershipService
    {
    
        /// <summary>
        /// Gets or sets the name of the application.
        /// </summary>
          string ApplicationName { get; set; }

        /// <summary>
        /// Gets a value indicating whether the current membership provider is configured
        ///     to allow users to reset their passwords.
        /// </summary>
          bool EnablePasswordReset { get; }

        /// <summary>
        /// Gets a value indicating whether the current membership provider is configured
        ///     to allow users to retrieve their passwords.
        /// </summary>
          bool EnablePasswordRetrieval { get; }

        /// <summary>
        /// Gets the number of invalid password or password-answer attempts allowed before
        ///     the membership user is locked out.
        /// </summary>
          int MaxInvalidPasswordAttempts { get; }

        /// <summary>
        /// Gets the minimum number of special characters that must be present in a valid
        ///     password.
        /// </summary>
          int MinRequiredNonAlphanumericCharacters { get; }

        /// <summary>
        /// Gets the minimum length required for a password.
        /// </summary>
          int MinRequiredPasswordLength { get; }

        /// <summary>
        /// Gets the time window between which consecutive failed attempts to provide
        ///     a valid password or password answer are tracked.
        /// </summary>
          int PasswordAttemptWindow { get; }

        /// <summary>
        /// Gets the regular expression used to evaluate a password.
        /// </summary>
          string PasswordStrengthRegularExpression { get; }

        /// <summary>
        /// Gets a value indicating whether the default membership provider requires
        ///     the user to answer a password question for password reset and retrieval.
        /// </summary>
          bool RequiresQuestionAndAnswer { get; }

        /// <summary>
        /// Adds a new user to the data store.
        /// 
        ///  Exceptions:
        ///   System.Web.Security.MembershipCreateUserException:
        ///     The user was not created. Check the System.Web.Security.MembershipCreateUserException.StatusCode
        ///     property for a System.Web.Security.MembershipCreateStatus value.
        /// </summary>
        /// <param name="username">The user name for the new user.</param>
        /// <param name="password">The password for the new user.</param>
        /// <returns>A System.Web.Security.MembershipUser object for the newly created user.</returns>
          MembershipCreateStatus CreateUser(string username, string password);

        /// <summary>
        /// Adds a new user with a specified e-mail address to the data store.
        /// 
        /// Exceptions:
        ///   System.Web.Security.MembershipCreateUserException:
        ///     The user was not created. Check the System.Web.Security.MembershipCreateUserException.StatusCode
        ///     property for a System.Web.Security.MembershipCreateStatus value.
        /// </summary>
        /// <param name="username">The user name for the new user.</param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <returns>A System.Web.Security.MembershipUser object for the newly created user.</returns>
          MembershipCreateStatus CreateUser(string username, string password, string email);

        /// <summary>
        /// Adds a new user with specified property values to the data store and returns
        ///     a status parameter indicating that the user was successfully created or the
        ///     reason the user creation failed.
        /// </summary>
        /// <param name="username">The user name for the new user.</param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <param name="passwordQuestion">The password-question value for the membership user.</param>
        /// <param name="passwordAnswer">The password-answer value for the membership user.</param>
        /// <param name="isApproved">A Boolean that indicates whether the new user is approved to log on.</param>
        /// <param name="status">A System.Web.Security.MembershipCreateStatus indicating that the user was
        ///     created successfully or the reason that creation failed.</param>
        /// <returns>A System.Web.Security.MembershipUser object for the newly created user. If
        ///     no user was created, this method returns null.</returns>
          MembershipCreateStatus CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved);

        /// <summary>
        /// Adds a new user with specified property values and a unique identifier to
        ///     the data store and returns a status parameter indicating that the user was
        ///     successfully created or the reason the user creation failed.
        /// </summary>
        /// <param name="username">The user name for the new user.</param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <param name="passwordQuestion">The password-question value for the membership user.</param>
        /// <param name="passwordAnswer">The password-answer value for the membership user.</param>
        /// <param name="isApproved">A Boolean that indicates whether the new user is approved to log on.</param>
        /// <param name="providerUserKey">The user identifier for the user that should be stored in the membership
        ///     data store.</param>
        /// <param name="status">A System.Web.Security.MembershipCreateStatus indicating that the user was
        ///     created successfully or the reason creation failed.</param>
        /// <returns>A System.Web.Security.MembershipUser object for the newly created user. If
        ///     no user was created, this method returns null.</returns>
          MembershipCreateStatus CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey);

        /// <summary>
        /// Deletes a user and any related user data from the database.
        /// Exceptions:
        ///   System.ArgumentException:
        ///     username is an empty string or contains a comma (,).
        ///
        ///   System.ArgumentNullException:
        ///     username is null.
        /// </summary>
        /// <param name="username">The name of the user to delete.</param>
        /// <returns>true if the user was deleted; otherwise, false.</returns>
          bool DeleteUser(string username);

        /// <summary>
        /// Deletes a user from the database.
        /// 
        /// Exceptions:
        ///   System.ArgumentException:
        ///     username is an empty string or contains a comma (,).
        ///
        ///   System.ArgumentNullException:
        ///     username is null.
        /// </summary>
        /// <param name="username">The name of the user to delete.</param>
        /// <param name="deleteAllRelatedData">true to delete data related to the user from the database; false to leave
        ///     data related to the user in the database.</param>
        /// <returns>true if the user was deleted; otherwise, false.</returns>
          bool DeleteUser(string username, bool deleteAllRelatedData);
       
        /// <summary>
        /// Gets a collection of membership users, in a page of data, where the e-mail
        ///     address contains the specified e-mail address to match.
        ///     
        /// Exceptions:
        ///   System.ArgumentException:
        ///     pageIndex is less than zero.-or-pageSize is less than 1.
        /// </summary>
        /// <param name="emailToMatch">The e-mail address to search for.</param>
        /// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">The total number of matched users.</param>
        /// <returns>A System.Web.Security.MembershipUserCollection that contains a page of pageSizeSystem.Web.Security.MembershipUser
        ///     objects beginning at the page specified by pageIndex.</returns>
          MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords);

        /// <summary>
        /// Gets a collection of membership users, in a page of data, where the user
        ///     name contains the specified user name to match.
        ///     
        /// Exceptions:
        ///   System.ArgumentException:
        ///     usernameToMatch is an empty string.-or-pageIndex is less than zero.-or-pageSize
        ///     is less than 1.
        ///
        ///   System.ArgumentNullException:
        ///     usernameToMatch is null.
        /// </summary>
        /// <param name="usernameToMatch">The user name to search for.</param>
        /// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">The total number of matched users.</param>
        /// <returns>A System.Web.Security.MembershipUserCollection that contains a page of pageSizeSystem.Web.Security.MembershipUser
        ///     objects beginning at the page specified by pageIndex.Leading and trailing
        ///     spaces are trimmed from the usernameToMatch parameter value.</returns>
          MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords);

        /// <summary>
        /// Gets a collection of all the users in the database in pages of data.
        /// </summary>
        /// <param name="pageIndex">The index of the page of results to return. Use 0 to indicate the first page.</param>
        /// <param name="pageSize">The size of the page of results to return. pageIndex is zero-based.</param>
        /// <param name="totalRecords">The total number of users.</param>
        /// <returns>A System.Web.Security.MembershipUserCollection of System.Web.Security.MembershipUser
        ///     objects representing all the users in the database for the configured applicationName.</returns>
          MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords);
 
        /// <summary>
        /// Gets the number of users currently accessing an application.
        /// </summary>
        /// <returns>The number of users currently accessing an application.</returns>
          int GetNumberOfUsersOnline();

        /// <summary>
        /// Gets the information from the data source for the membership user associated
        ///     with the specified unique identifier.
        ///     
        /// System.ArgumentNullException:
        ///     providerUserKey is null.
        /// </summary>
        /// <param name="providerUserKey">The unique user identifier from the membership data source for the user.</param>
        /// <returns>A System.Web.Security.MembershipUser object representing the user associated
        ///     with the specified unique identifier.</returns>
          MembershipUser GetUser(object providerUserKey);

        /// <summary>
        /// Gets the information from the data source for the specified membership user.
        /// 
        /// Exceptions:
        ///   System.ArgumentException:
        ///     username contains a comma (,).
        ///
        ///   System.ArgumentNullException:
        ///     username is null.
        /// </summary>
        /// <param name="username">The name of the user to retrieve.</param>
        /// <returns>A System.Web.Security.MembershipUser object representing the specified user.</returns>
          MembershipUser GetUser(string username);
  
        /// <summary>
        /// Gets the information from the data source for the membership user associated
        ///     with the specified unique identifier. Updates the last-activity date/time
        ///     stamp for the user, if specified.
        ///     
        /// Exceptions:
        ///   System.ArgumentNullException:
        ///     providerUserKey is null.
        /// </summary>
        /// <param name="providerUserKey">The unique user identifier from the membership data source for the user.</param>
        /// <param name="userIsOnline">If true, updates the last-activity date/time stamp for the specified user.</param>
        /// <returns>A System.Web.Security.MembershipUser object representing the user associated
        ///     with the specified unique identifier.</returns>
          MembershipUser GetUser(object providerUserKey, bool userIsOnline);
        
        /// <summary>
        /// Gets the information from the data source for the specified membership user.
        ///     Updates the last-activity date/time stamp for the user, if specified.
        ///    
        /// Exceptions:
        ///   System.ArgumentException:
        ///     username contains a comma (,).
        ///
        ///   System.ArgumentNullException:
        ///     username is null.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="userIsOnline"></param>
        /// <returns></returns>
          MembershipUser GetUser(string username, bool userIsOnline);

        /// <summary>
        /// Gets a user name where the e-mail address for the user matches the specified
        ///     e-mail address.
        /// </summary>
        /// <param name="emailToMatch">The e-mail address to search for.</param>
        /// <returns>The user name where the e-mail address for the user matches the specified
        ///     e-mail address. If no match is found, null is returned.</returns>
          string GetUserNameByEmail(string emailToMatch);
 
        /// <summary>
        /// Updates the database with the information for the specified user.
        /// 
        /// Exceptions:
        ///   System.ArgumentNullException:
        ///     user is null.
        /// </summary>
        /// <param name="user">A System.Web.Security.MembershipUser object that represents the user to be
        ///     updated and the updated information for the user.</param>
          void UpdateUser(MembershipUser user);

        /// <summary>
        /// Verifies that the supplied user name and password are valid.
        /// </summary>
        /// <param name="username">The name of the user to be validated.</param>
        /// <param name="password">The password for the specified user.</param>
        /// <returns>true if the supplied user name and password are valid; otherwise, false.</returns>
          bool ValidateUser(string username, string password);

    }
}
